<?php
/**
 * @package     crafts-usa.Site
 * @subpackage  Templates.crafts-usa
 *
 * @copyright   Copyright (C) 2013. All rights reserved.
 * @license     Crafts USA by Wholesalers USA
 */

defined('_JEXEC') or die;

// Getting params from template
$params = JFactory::getApplication()->getTemplate(true)->params;

$app = JFactory::getApplication();
$doc = JFactory::getDocument();
$this->language = $doc->language;
$this->direction = $doc->direction;

// Detecting Active Variables
$option   = $app->input->getCmd('option', '');
$view     = $app->input->getCmd('view', '');
$layout   = $app->input->getCmd('layout', '');
$task     = $app->input->getCmd('task', '');
$itemid   = $app->input->getCmd('Itemid', '');
$sitename = $app->getCfg('sitename');

if($task == "edit" || $layout == "form" )
{
	$fullWidth = 1;
}
else
{
	$fullWidth = 0;
}

// Add JavaScript Frameworks
//JHtml::_('bootstrap.framework');
//$doc->addScript('templates/' .$this->template. '/js/jquery.js');
//$doc->addScript('templates/' .$this->template. '/js/bootstrap.js');

// Add Stylesheets
$doc->addStyleSheet('templates/'.$this->template.'/css/bootstrap.css');
$doc->addStyleSheet('templates/'.$this->template.'/css/main.css');
$doc->addStyleSheet('templates/'.$this->template.'/css/menu.css');
$doc->addStyleSheet('templates/'.$this->template.'/css/media.css');

// Load optional RTL Bootstrap CSS
//JHtml::_('bootstrap.loadCss', false, $this->direction);

// Add current user information
$user = JFactory::getUser();

// Adjusting content width
if (!$this->countModules('right'))
{
	$span = "noright";
}
else
{
	$span = "right";
}

// Logo file or site title param
if ($this->params->get('logoFile'))
{
	$logo = '<img src="'. JUri::root() . $this->params->get('logoFile') .'" alt="'. $sitename .'" />';
}
elseif ($this->params->get('sitetitle'))
{
	$logo = '<span class="site-title" title="'. $sitename .'">'. htmlspecialchars($this->params->get('sitetitle')) .'</span>';
}
else
{
	$logo = '<span class="site-title" title="'. $sitename .'">'. $sitename .'</span>';
}
?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo $this->language; ?>" lang="<?php echo $this->language; ?>" dir="<?php echo $this->direction; ?>">
<head>

	<meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <link rel="shortcut icon" href="<?php echo JURI::base() . 'templates/' . $this->template .'/ico/favicon.png'?>" />
    
	<jdoc:include type="head" />
    	
	<!--[if lt IE 9]>
		<script src="<?php echo $this->baseurl ?>/media/jui/js/html5.js"></script>
	<![endif]-->
	<link href="<?php echo JURI::base() . 'templates/' . $this->template .'/js/video-js/video-js.css'?>" rel="stylesheet" />
	<script src="<?php echo JURI::base() . 'templates/' .  $this->template . '/js/video-js/video.js'?>" type="text/javascript"></script>
	<script>
	  //mvp - if it is IE9 - the first line tests for IE9 - then fall back to flash
	  /*
	  if(navigator.userAgent.indexOf("Trident/5")>-1){
	  	_V_.options.techOrder = ["flash"];
	    _V_.options.flash.swf = "templates/<?php echo $this->template ?>/swf/video-js.swf";
	  }*/
	</script>	
    
    <!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
	<!--[if lt IE 9]>
		<script src="<?php echo JURI::base() . 'templates/' . $this->template .'/js/html5shiv.js'?>"></script>
		<script src="<?php echo JURI::base() . 'templates/' . $this->template .'/js/respond.min.js'?>"></script>
		<link rel="stylesheet" type="text/css" href="<?php echo JURI::base() . 'templates/' . $this->template .'/css/ie8.css'?>" />
	<![endif]-->
	<!--[if IE 7]>
  		<link rel="stylesheet" type="text/css" href="<?php echo JURI::base() . 'templates/' . $this->template .'/css/ie7.css'?>" />
	<![endif]-->
    
    <?php if($_REQUEST['option'] == 'com_content' AND $_REQUEST['view'] == 'article'): ?>
        <link rel="stylesheet" type="text/css" href="<?php echo JURI::base() . 'templates/' . $this->template .'/css/article.css'?>" />
    <?php endif; ?>


  <script type="text/javascript">
  //<!--
    jQuery(document).ready(function() {  
        jQuery('.navbar-toggle').bind('click', function(e) {
    	    var navBar = jQuery(this).attr('data-target');
            if (jQuery(navBar).hasClass('mobile_menu')) {
                if (jQuery(navBar).hasClass('in')) {
                    jQuery(navBar).removeClass('in');
                } else {
                    jQuery(navBar).addClass('in');
                    jQuery(navBar).css('height', 'auto');
                }
             } else {
                 jQuery(navBar).addClass('mobile_menu');
             }   
          });
          
          jQuery('.navbar-toggle').bind('touchstart', function(e) {
            var navBar = jQuery(this).attr('data-target');
            if (jQuery(navBar).hasClass('mobile_menu')) {
                if (jQuery(navBar).hasClass('in')) {
                    jQuery(navBar).removeClass('in');
                } else {
                    jQuery(navBar).addClass('in');
                    jQuery(navBar).css('height', 'auto');
                }
             } else {
                 jQuery(navBar).addClass('mobile_menu');
             }   
          });
          
    });
    //-->
  </script>

    	
</head>

<body class="site <?php echo $option
	. ' view-' . $view
	. ($layout ? ' layout-' . $layout : ' no-layout')
	. ($task ? ' task-' . $task : ' no-task')
	. ($itemid ? ' itemid-' . $itemid : '')
	. ($params->get('fluidContainer') ? ' fluid' : '');
?>">

	<div class="wrapper container">
    	<div class="header clearfix">
    		<div class="header-left">
                <jdoc:include type="modules" name="breadcrumbs" style="xhtml" />
        		<div class="logoWrap">
                    <div class="crafts-logo"><a href="<?php echo $this->baseurl; ?>">
                        <?php echo $logo;?> <?php if ($this->params->get('sitedescription')) { echo '<div class="site-description">'. htmlspecialchars($this->params->get('sitedescription')) .'</div>'; } ?>
                    </a></div>
                    <?php if ($this->countModules('logo')) { ?>
                    <div class="wholesalers-logo">
                        <jdoc:include type="modules" name="logo" style="none" /> 
                    </div>
                    <?php } ?>
                </div>

    		</div>
    		<div class="header-right">
                <?php if ($this->countModules('shop')) { ?>
    			<div class="moduletable-clicktoshop">
                    <jdoc:include type="modules" name="shop" style="none" />
                </div>
                <?php } ?>
                <?php if ($this->countModules('search')) { ?>
    			<div class="moduletable-search">
                    <jdoc:include type="modules" name="search" style="none" />
    			</div>
                <?php } ?>
                <?php if ($this->countModules('social')) { ?>
    			<div class="moduletable-social">
                    <jdoc:include type="modules" name="social" style="none" />
                </div>
                <?php } ?>
    		</div>
    	</div>
    	
    	<div class="navbar navbar-inverse">
    		<div class="navbar-header">
    			<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
    				<span class="icon-bar"></span>
    				<span class="icon-bar"></span>
    				<span class="icon-bar"></span>
    			</button>
    		</div>
    		<div class="navbar-collapse collapse">
                <jdoc:include type="modules" name="menu" style="none" />
    		</div><!--/.navbar-collapse -->
    	</div>
    	<?php if ($this->countModules('banner')) { ?>
    	<div class="bannerWrap row">
            <jdoc:include type="modules" name="banner" style="none" />
    	</div>
    	<?php } ?>
        <?php if ($this->countModules('add')) { ?>
    	<div class="add">
            <jdoc:include type="modules" name="add" style="none" />
        </div>
    	<?php } ?>
    	<div class="container">
    		<div class="row">
    			<div class="contentCol col-md-9 col-sm-8 <?php echo $span;?>">
    				<div class="content">
    					<jdoc:include type="message" />
    					<jdoc:include type="component" />
                    </div>
                    <?php if ($this->countModules('featured')) { ?>
    				<div class="featured-module">
                        <jdoc:include type="modules" name="featured" style="xhtml" />
    				</div>
                    <?php } ?>
    			</div>
                <?php if ($this->countModules('right')) { ?>
    			<div class="rightCol col-md-3 col-sm-4">
                    <jdoc:include type="modules" name="right" style="xhtml" />
    			</div>
                <?php } ?>
    		</div>
    
    		<footer>
                <jdoc:include type="modules" name="footer" style="xhtml" />
    		</footer>
    	</div> <!-- /container -->
    </div>

<!-- Google Analytics Start-->
<script type="text/javascript">
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-231296-1']);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();
</script>
<!-- End of Google Analytics -->

</body>
</html>
